/**
 * @file queue.cpp
 * @author 逆流 (1171267147@qq.com)
 * @brief
 * @version 0.1
 * @date 2024-10-15
 *
 * @copyright Copyright (c) 2024
 *
 */

#include <gtest/gtest.h>

#include "stl/container/queue.hpp"

using stl::Queue;

TEST(Queue, Init) {
    Queue<int> queue1;
    EXPECT_TRUE(queue1.Empty());
    EXPECT_EQ(queue1.length(), 0);

    Queue<int> queue2{1, 2, 3, 4, 5};
    EXPECT_FALSE(queue2.Empty());
    EXPECT_EQ(queue2.length(), 5);
    EXPECT_EQ(queue2.Front(), 1);
    queue2.Clear();
    EXPECT_TRUE(queue2.Empty());
    EXPECT_EQ(queue2.length(), 0);
}

TEST(Queue, EnqueueAndDequeue) {
    Queue<int> queue;
    queue.Enqueue(1);
    queue.Enqueue(2);
    queue.Enqueue(3);
    EXPECT_EQ(queue.length(), 3);
    EXPECT_EQ(queue.Front(), 1);

    queue.Dequeue();
    EXPECT_EQ(queue.length(), 2);
    EXPECT_EQ(queue.Front(), 2);
    EXPECT_EQ(queue.Dequeue(), 2);
    EXPECT_EQ(queue.Dequeue(), 3);

    EXPECT_THROW(queue.Dequeue(), std::out_of_range);
}
